package countVowelSubstrings;

public class Solution {
    public int countVowelSubstrings(String word) {
        //
        int ans = 0;
        for (int i = 0; i < word.length(); i++) {
            for (int j = i; j < word.length(); j++) {
                if(check(word.substring(i,j+1))) {
                    ans++;
                }
            }
        }
        return ans;
    }
    private boolean check(String s) {
        // 必须包含aeiou
        int a,e,i,o,u;
        a = e = i = o = u = 0;
        for (int j = 0; j < s.length(); j++) {
            char c = s.charAt(j);
            if(c == 'a') {
                a++;
            } else if (c == 'e') {
                e++;
            } else if (c == 'i') {
                i++;
            } else if (c == 'o') {
                o++;
            } else if(c == 'u'){
                u++;
            }
        }
        return a*e*i*o*u!=0&&(a+e+i+o+u) == s.length();
    }
}
